// 基于template/src/widgets/\{{appEntities}}/\{{ctrls@DASHBOARD}}-dashboard/\{{spinalCase ctrl.codeName}}-dashboard-model.ts.hbs生成
import { IDashboardModel } from "@/core";

function getModel(): IDashboardModel {
    return {
        name: "{{ctrl.name}}",
        caption: "{{ctrl.caption}}",
        codeName: "{{ctrl.codeName}}",
        cssName: "{{#if ctrl.psSysCss}}{{ctrl.psSysCss.cssName}}{{/if}}",
        controlType: "{{ctrl.controlType}}",
        isEnableCustomized: {{ctrl.enableCustomized}},
        entityName:"{{lowerCase appEntity.codeName}}",
        portletArray:[
        {{#each ctrl.psControls as | portlet |}}
        {{> @macro/widgets/dashboard/portlet-model.hbs item=portlet}}
        {{/each}}
        ],
        actionGroup:{
        {{#each ctrl.psControls as | portlet |}}
            {{portlet.name}}:[
                {{#each portlet.psUIActionGroup.psUIActionGroupDetails as | a |}}
                {
                    name: "{{a.name}}",
                    caption: "{{a.psUIAction.caption}}",
                    showIcon: {{a.showIcon}},
                    showCaption: {{a.showCaption}},
                    separator: {{a.addSeparator}},
                    uIActionTag: "{{a.psUIAction.uIActionTag}}",
                    noPrivDisplayMode: "{{a.psUIAction.noPrivDisplayMode}}",
                    dataAccessAction: '{{a.psUIAction.dataAccessAction}}',
                    actionTarget: '{{a.psUIAction.actionTarget}}',
                    uIActionMode: "{{a.psUIAction.uIActionMode}}",
                    disabled: false,
                    visible: true,
                    {{#if portlet.psAppViewLogics}}
                        {{#each portlet.psAppViewLogics as | logic |}}
                            {{#eq logic.name (concat portlet.name '_' a.name '_click')}}
                    logic: {
                        name: '{{logic.name}}',
                        actionTag: '{{#if a.psUIAction}}{{a.psUIAction.uIActionTag}}{{/if}}',
                        xDataCtrlName: '{{portlet.name}}',
                        {{#and a.psUIAction a.psUIAction.psAppDataEntity}}
                        actionDECodeName: '{{a.psUIAction.psAppDataEntity.codeName}}',
                        {{/and}}
                        predefinedType: '{{#if a.psUIAction.psUIAction}}{{a.psUIAction.predefinedType}}{{/if}}'
                    },
                            {{/eq}}
                        {{/each}}
                    {{/if}}
                    {{#if a.psUIAction.psSysImage}}
                        {{#if a.psUIAction.psSysImage.imagePath}}
                    imgPath: "{{a.psUIAction.psSysImage.imagePath}}",
                        {{/if}}
                        {{#if a.psUIAction.psSysImage.cssClass}}
                    iconClass: "{{a.psUIAction.psSysImage.cssClass}}",
                        {{/if}}
                    {{/if}}
                },
            {{/each}}
            ],
        {{/each}}
        }
    }
}
export const model = getModel();
